<?php
namespace common\components\grid;

use yii\helpers\Html;

/**
 * 
 * @Description: 编辑列表页某个字段的值 
 * @author: kai.gao
 * @date: 2014-11-20 下午11:43:35
 */
class EditableColumn2015 extends \kartik\grid\EditableColumn {
	public function init() {
		parent::init();
		$this->editableOptions =  function ($model, $key, $index) {
			return [
				'formOptions' => [
					'action' => ['common/editable']
				],
				'submitButton' => [
					'class' => 'btn btn-sm btn-primary',
					'label' => '<i class="glyphicon glyphicon-save"></i> 提交',
				],
				'preHeader' => '<i class="glyphicon glyphicon-edit"></i> 编辑 ',
				'resetButton' => [
					'class' => 'btn btn-sm btn-default',
					'label' => '<i class="glyphicon glyphicon-repeat"></i> 重置',
				],
				'options' => ['name' => 'new_value'],
				'beforeInput' => Html::hiddenInput('class_name', get_class($model)),
				'afterInput' => function($form, $widget) use ($model, $index) {
					$old_value = $widget->model->oldAttributes[$widget->attribute];
					echo
					 Html::hiddenInput('field', $widget->attribute)
					.Html::hiddenInput('old_value', $old_value);
				}
			];
		};
	}
}
